from module.static_module.parent.view import SubWindowView
from module.static_module.main_window.view import MainWindowView

from tools.view import *


class DataBridgeView(SubWindowView):
    def __init__(self, main_window_view: MainWindowView):
        super().__init__(main_window_view)
        self.class_name = Module.DataBridge.value
        tk.Label(self.frame, text=self.class_name).pack()

    def create_layout_init(self):
        # 绘制标签、内容组件
        # 配置参数
        # 当前模型名
        now_model_name = self.main_window_view.master.file_manager.now_model_name

        symbol_name_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].symbol_name_ls
        trading_variety_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].trading_variety_ls
        fighting_mode_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].fighting_mode_ls
        k_interval_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].k_interval_ls
        count_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].count_ls
        start_time_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].start_time_ls
        end_time_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].end_time_ls
        software_path_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].software_path_ls
        factor_name_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].factor_name_ls
        text_box_ls = self.main_window_view.master.dynamic_module_model_dc[
            self.main_window_view.master.file_manager.now_dynamic_module].text_box_ls

        label_config = [
            [LabelMember.ModelName, WidgetCategory.Label, [now_model_name], [0]],
            [LabelMember.SymbolName, WidgetCategory.ScrolledText, symbol_name_ls, [0]],
            [LabelMember.TradingVariety, WidgetCategory.Combobox, trading_variety_ls, [0]],
            [LabelMember.FightingMode, WidgetCategory.Combobox, fighting_mode_ls, [0]],
            [LabelMember.KInterval, WidgetCategory.Combobox, k_interval_ls, [0]],
            [LabelMember.Count, WidgetCategory.Entry, count_ls, [0]],
            [LabelMember.StartTime, WidgetCategory.Entry, start_time_ls, [0]],
            [LabelMember.EndTime, WidgetCategory.Entry, end_time_ls, [0]],
            [LabelMember.SoftwarePath, WidgetCategory.Entry, software_path_ls, [0]],
            [LabelMember.FactorName, WidgetCategory.CheckButton, factor_name_ls, []]
        ]

        button_config = [
            [ButtonMember.Run, WidgetCategory.Button, None],
            [ButtonMember.Stop, WidgetCategory.Button, None],
            [ButtonMember.OnlyData, WidgetCategory.Button, None]
        ]
        self.auto_layout = AutoLayout(self.frame, label_config, button_config)
        self.auto_layout.button_command(self)




